# define the deploy proto
# for the testing
import caffe
from caffe import layers as L,params as P
# root_file_path = "/home/sunzy/workspace/pyhome/CaffeProject/CaffeProject/pulsar/deep_learning/temp/"

name = "subbands"

root_file_path = "/home/dataology/workspace/caffe/CaffeProject/pulsar/deep_learning/temp/"
deploy = root_file_path+'%s/deploy.prototxt' % name

def create_deploy():
    n = caffe.NetSpec()
    n.conv1 = L.Convolution(bottom='data', kernel_size=5, num_output=20, weight_filler=dict(type='xavier'))
    n.pool1 = L.Pooling(n.conv1, kernel_size=2, stride=2, pool=P.Pooling.MAX)
    n.conv2 = L.Convolution(n.pool1, kernel_size=5, num_output=50, weight_filler=dict(type='xavier'))
    n.pool2 = L.Pooling(n.conv2, kernel_size=2, stride=2, pool=P.Pooling.MAX)
    n.fc1 = L.InnerProduct(n.pool2, num_output=500, weight_filler=dict(type='xavier'))
    n.relu1 = L.ReLU(n.fc1, in_place=True)
    # num of output is 2
    n.score = L.InnerProduct(n.relu1, num_output=2, weight_filler=dict(type='xavier'))
    n.prob = L.Softmax(n.score)
    return n.to_proto()

def write_deploy():
    with open(deploy, 'w') as f:
        f.write('name:"Lenet"\n')
        f.write('input:"data"\n')
        f.write('input_dim:1\n')
        f.write('input_dim:1\n')
        f.write('input_dim:18\n')
        f.write('input_dim:64\n')
        f.write(str(create_deploy()))

if __name__ == '__main__':
    write_deploy()